package com.ruoyi.web.controller.kaoyan.vo;

import com.ruoyi.kaoyan.domain.EducationCategory;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * 分类管理vo类
 * @author admin
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CategoryVo {

    private Long id;
    private String name;
    private Long pid;
    private String categoryLevel;
    private String iconGroupId;
    private String iconPath;
    private List<CategoryVo> children;

    public CategoryVo (EducationCategory category, Map<String, String> filePathMap, Map<Long, List<CategoryVo>> map){
        this.id = category.getId();
        this.name = category.getName();
        this.pid = category.getPid();
        this.categoryLevel = category.getCategoryLevel();
        String iconGroupId = category.getIconGroupId();
        this.iconPath = filePathMap.get(Optional.ofNullable(iconGroupId).orElse("0"));
        this.children = map.get(category.getId());
    }

    public CategoryVo(EducationCategory category){
        this.id = category.getId();
        this.name = category.getName();
        this.pid = category.getPid();
        this.categoryLevel = category.getCategoryLevel();
        this.iconGroupId = category.getIconGroupId();
    }
}
